/*
 */

#import "NSArray+LCAddition.h"

@implementation NSArray (LCAddition)

+ (instancetype)lc_arrayWithPlist:(NSString *)plistName andClassName:(NSString *)clzName{
    NSURL *url = [[NSBundle mainBundle] URLForResource:plistName withExtension:nil];
    //    (nil == url) ? NSLog(@"url_err") : NSLog(@"url_ok");
    NSAssert(nil != url, @"url_err  plist文件不对");
    NSArray *array = [NSArray arrayWithContentsOfURL:url];
    NSMutableArray *arrayM = [NSMutableArray array];
    Class clz = NSClassFromString(clzName);
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-variable"
    NSString *strNil = [NSString stringWithFormat:@"%@类名不正确",clzName];
#pragma clang diagnostic pop
    NSAssert(clz != nil, @"%@",strNil);
    [array enumerateObjectsUsingBlock:^(NSDictionary *dict, NSUInteger idx, BOOL * _Nonnull stop) {
        NSObject *model = [[clz alloc] init];
        [model setValuesForKeysWithDictionary:dict];
        [arrayM addObject:model];
    }];
    return arrayM.copy;
}
@end
